package com.kssoft.ebd.spider.scheduler;

import com.alibaba.fastjson.JSON;
import com.kssoft.ebd.spider.processor.HomeProcessor;
import com.kssoft.ebd.spider.processor.StartBroadcastProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class RenewalScheduler {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private HomeProcessor homeProcessor;
    @Autowired
    private StartBroadcastProcessor startBroadcastProcessor;
    /**
     * 刷新主页cookies，每半小时执行一次
     */
    @Scheduled(cron ="0 0/30 * * * ?")
    public void TMShuScheduled() {
        logger. info(" 开始执行调度----------------------续期cookies");
        Map<String, String> homeCookies = homeProcessor.getHomeCookies();

        logger. info(" 执行调度----------------------续期主页cookies：" + JSON.toJSONString(homeCookies));

        Map<String, String> startBroadcastCookies = startBroadcastProcessor.getStartBroadcastCookies();
        logger. info(" 执行调度----------------------续期开播主页cookies：" + JSON.toJSONString(startBroadcastCookies));
    }
}


